#include <iostream>
#include <vector>
using namespace std;

vector<vector<int>> generate(int numRows) {
    vector<vector<int>> ans(numRows);
    for (int i = 0; i < numRows; i++)
    {
        ans[i].resize(i + 1, 0);
        ans[i][0] = 1;
        ans[i][i] = 1;
    }

    for (int i = 2; i < numRows; i++)
    {
        for (int j = 1; j < i; j++)
        {
            ans[i][j] = ans[i - 1][j - 1] + ans[i - 1][j];
        }
    }

    return ans;
}

int main()
{
    vector<vector<int>> ret = generate(5);
    for (auto a : ret)
    {
        for (auto b : a)
        {
            cout << b << ' ';
        }
        cout << endl;
    }
    return 0;
}